package com.zcy.feign;

import com.zcy.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
//UserClient 表示对那个接口进行托底处理(熔断情况下触发的方法)
public class HystrixFallbackFactory implements FallbackFactory<UserClient> {
    public UserClient create(Throwable throwable) {
        return new UserClient() {//匿名内部类
            public User findById(Long id) {
                User user = new User();
                user.setId(id);
                user.setOtherName("hystrix发生熔断后触发的方法");
                return user;
            }
        };
    }
}
